<?xml version="1.0" encoding="ISO-8859-1" ?>

<html xmlns="http://www.w3.org/1999/xhtml" 
	  xmlns:h="http://java.sun.com/jsf/html" 
	  xmlns:f="http://java.sun.com/jsf/core"
	  xmlns:c="http://java.sun.com/jsp/jstl/core"
	  xmlns:p="http://primefaces.org/ui"
	  xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head>

</h:head> 

<h:body>
	<ui:composition template="/template.xhtml">

		<ui:define name="conteudo">
			<H1><p:outputLabel value="#{msg.usuario}"/></H1>
			<h:form enctype="multipart/form-data" styleClass="formUsuarioForm">
				<h:panelGrid columns="2" id="formUsuario" styleClass="painelUsuarioForm">
					
					<h:outputLabel value="#{msg.login}" />
					<h:panelGroup>
						<h:inputText id="login" label="#{msg.login}" value="#{usuarioManagedBean.usuario.login}" required="true" 
												disabled="#{empty usuarioManagedBean.usuario.login ? false : true }" validator="#{formValidator.validateLogin}">
							<f:validateLength minimum="3" maximum="50" />
						</h:inputText>
						<h:message for="login" showDetail="false" showSummary="true" />
					</h:panelGroup>
					
					<h:outputLabel value="#{msg.senha}" />
					<h:panelGroup>
					    <h:inputSecret id="senha" label="#{msg.senha}" value="#{usuarioManagedBean.usuario.senha}" redisplay="true" required="true">
							<f:validateLength minimum="4" maximum="15" />
						</h:inputSecret>
						<h:message for="senha" showDetail="false" showSummary="true" />
					</h:panelGroup>
					
					<h:outputLabel value="#{msg.tipo}" />
					<h:panelGroup>
					<h:selectOneMenu label="#{msg.tipo}" id="tipo" value="#{usuarioManagedBean.usuario.tipo}" disabled="#{usuarioManagedBean.usuario.tipo > 0 ? true : false }">
						<f:selectItem itemLabel="" itemValue="null"/>
						<f:selectItem itemLabel="Moderador" itemValue="1"/>
						<f:selectItem itemLabel="Professor" itemValue="2"/>
						<f:selectItem itemLabel="Aluno" itemValue="3"/>
						<f:ajax event="change" execute="formUsuario" render="@form"/>
					</h:selectOneMenu>
						<h:message for="tipo" showDetail="false" showSummary="true" />
					</h:panelGroup>
					
					<h:outputLabel value="#{msg.fotoPerfil} " rendered="#{loginManagedBean.usuario.tipo!=4}"/>
					<h:panelGroup rendered="#{loginManagedBean.usuario.tipo!=4}">
						<p:fileUpload id="arquivo" value="#{usuarioManagedBean.arquivo}" mode="simple"  
									  auto="true" validator="#{formValidator.validateArquivo}" allowTypes="/(\.|\/)(gif|jpe?g|png)$/"
									  multiple="false" required="false"/> 
						<h:message for="arquivo" showDetail="false" showSummary="true" />		  
					</h:panelGroup>
				</h:panelGrid>
				
				<h:panelGrid columns="2" id="formModerador" rendered="#{usuarioManagedBean.usuario.tipo==1}">
					<h:outputLabel value="#{msg.curso} "/>
					<h:panelGroup>
						<h:selectOneMenu id="cursoModerador" value="#{usuarioManagedBean.moderadorManagedBean.moderador.curso}" label="#{msg.curso}" converter="CursoConverter">
							<f:selectItem itemValue="" itemLabel="" />								
							<f:selectItems value="#{usuarioManagedBean.moderadorManagedBean.cursos}" var="curso" itemLabel="#{curso.nome}" itemValue="#{curso}"/>
						</h:selectOneMenu>
							<h:message for="cursoModerador" showSummary="true" showDetail="false" />
					</h:panelGroup>
						
					<h:outputLabel value="#{msg.matricula}"/>
					<h:panelGroup>
						<p:inputMask id="matriculaModerador" label="#{msg.matricula}" mask="UC99999999"
									 value="#{usuarioManagedBean.moderadorManagedBean.moderador.matricula}" required="true" 
									 validator="#{formValidator.validateMatricula}"/>
							
						<h:message for="matriculaModerador" showDetail="false" showSummary="true"/>
					</h:panelGroup>
					
					<h:outputLabel value="#{msg.nome}"/>
					<h:panelGroup>
						<h:inputText id="nomeModerador" label="#{msg.nome}" value="#{usuarioManagedBean.moderadorManagedBean.moderador.nome}" required="true">
							<f:validateLength maximum="120"/>
						</h:inputText>
						<h:message for="nomeModerador" showDetail="false" showSummary="true"/>
					</h:panelGroup>
					
					<h:outputLabel value="#{msg.dataNasc}"/>
					<h:panelGroup>
						<p:calendar id="dataNascModerador" label="#{msg.dataNasc}" value="#{usuarioManagedBean.moderadorManagedBean.moderador.dataNasc}" required="true" pattern="dd/MM/yyyy"/>
						<h:message for="dataNascModerador" showDetail="false" showSummary="true"/>
					</h:panelGroup>
					
					<h:outputLabel value="#{msg.telefone}"/>
					<h:panelGroup>
						<p:inputMask id="telefoneModerador" label="#{msg.telefone}" mask="(99)9999-9999" 
									 value="#{usuarioManagedBean.moderadorManagedBean.moderador.telefone}" required="true" />
						<h:message for="telefoneModerador" showDetail="false" showSummary="true"/>
					</h:panelGroup>
					
					<h:outputLabel value="#{msg.email}"/>
					<h:panelGroup>
						<h:inputText id="emailModerador" label="#{msg.email}"
									 value="#{usuarioManagedBean.moderadorManagedBean.moderador.email}" required="true">
							<f:validateRegex pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" />
						</h:inputText>
						<h:message for="emailModerador" showDetail="false" showSummary="true"/>
					</h:panelGroup>
					
					<h:outputLabel value="#{msg.perfil}"/>
					<h:panelGroup>
						<h:inputText id="perfilModerador" label="#{msg.perfil}" value="#{usuarioManagedBean.moderadorManagedBean.moderador.perfil}">
							<f:validateLength maximum="300"/>
						</h:inputText>
						<h:message for="perfilModerador" showDetail="false" showSummary="true"/>
					</h:panelGroup>
					
					<h:outputLabel value="#{msg.titulacao}"/>
					<h:panelGroup>
						<h:inputText id="titulacaoModerador" label="#{msg.titulacao}" value="#{usuarioManagedBean.moderadorManagedBean.moderador.titulacao}" required="true">
							<f:validateLength maximum="30"/>
						</h:inputText>
						<h:message for="titulacaoModerador" showDetail="false" showSummary="true"/>
					</h:panelGroup>				
				</h:panelGrid>

		

				<h:panelGrid columns="2" rendered="#{usuarioManagedBean.usuario.tipo==2}">
					<h:outputLabel value="#{msg.matricula} "/>
					<h:panelGroup>
						<p:inputMask id="matriculaProfessor" label="#{msg.matricula}" mask="UC99999999"
									 value="#{usuarioManagedBean.professorManagedBean.professor.matricula}" required="true"  
									 validator="#{formValidator.validateMatricula}"/>
						<h:message for="matriculaProfessor" showDetail="false" showSummary="true"/>
					</h:panelGroup>
					
					<h:outputLabel value="#{msg.nome} "/>
					<h:panelGroup>
						<h:inputText id="nomeProfessor" label="#{msg.nome}" value="#{usuarioManagedBean.professorManagedBean.professor.nome}" required="true">
							<f:validateLength maximum="120"/>
						</h:inputText>
						<h:message for="nomeProfessor" showDetail="false" showSummary="true"/>
					</h:panelGroup>
					
					<h:outputLabel value="#{msg.dataNasc} "/>
					<h:panelGroup>
						<p:calendar id="dataNascProfessor" label="#{msg.dataNasc}" value="#{usuarioManagedBean.professorManagedBean.professor.dataNasc}" required="true" pattern="dd/MM/yyyy" />
						<h:message for="dataNascProfessor" showDetail="false" showSummary="true"/>
					</h:panelGroup>
					
					<h:outputLabel value="#{msg.telefone} "/>
					<h:panelGroup>
						<p:inputMask id="telefoneProfessor" label="#{msg.telefone}" mask="(99)9999-9999"
									 value="#{usuarioManagedBean.professorManagedBean.professor.telefone}" required="true" />
						<h:message for="telefoneProfessor" showDetail="false" showSummary="true"/>
					</h:panelGroup>
					
					<h:outputLabel value="#{msg.email} "/>
					<h:panelGroup>
						<h:inputText id="emailProfessor" label="#{msg.email}" value="#{usuarioManagedBean.professorManagedBean.professor.email}" required="true">
							<f:validateRegex pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" />
						</h:inputText>
						<h:message for="emailProfessor" showDetail="false" showSummary="true"/>
					</h:panelGroup>
					
					<h:outputLabel value="#{msg.perfil}"/>
					<h:panelGroup>
						<h:inputText id="perfilProfessor" label="#{msg.perfil}" value="#{usuarioManagedBean.professorManagedBean.professor.perfil}">
							<f:validateLength maximum="300"/>
						</h:inputText>
						<h:message for="perfilProfessor" showDetail="false" showSummary="true"/>
					</h:panelGroup>
					
					<h:outputLabel value="#{msg.titulacao}"/>
					<h:panelGroup>
						<h:inputText id="titulacaoProfessor" label="#{msg.titulacao}" value="#{usuarioManagedBean.professorManagedBean.professor.titulacao}" required="true">
							<f:validateLength maximum="30"/>
						</h:inputText>
						<h:message for="titulacaoProfessor" showDetail="false" showSummary="true"/>
					</h:panelGroup>
				</h:panelGrid>
	
			
			
				<h:panelGrid columns="2" rendered="#{usuarioManagedBean.usuario.tipo==3}">
					<h:outputLabel value="#{msg.curso} "/>
					<h:panelGroup>
						<h:selectOneMenu id="cursoAluno" value="#{usuarioManagedBean.alunoManagedBean.aluno.curso}" label="#{msg.curso}" converter="CursoConverter">
							<f:selectItem itemValue="" itemLabel="" />								
							<f:selectItems value="#{usuarioManagedBean.alunoManagedBean.cursos}" var="curso" itemLabel="#{curso.nome}" itemValue="#{curso}"/>
						</h:selectOneMenu>
							<h:message for="cursoAluno" showSummary="true" showDetail="false" />
					</h:panelGroup>
				
					<h:outputLabel value="#{msg.matricula}"/>
					<h:panelGroup>
						<p:inputMask id="matriculaAluno" label="#{msg.matricula}" mask="UC99999999"
									 value="#{usuarioManagedBean.alunoManagedBean.aluno.matricula}" required="true" 
									 validator="#{formValidator.validateMatricula}"/>
						<h:message for="matriculaAluno" showDetail="false" showSummary="true"/>
					</h:panelGroup>
					
					<h:outputLabel value="#{msg.nome}"/>
					<h:panelGroup>
						<h:inputText id="nomeAluno" label="#{msg.nome}" value="#{usuarioManagedBean.alunoManagedBean.aluno.nome}" required="true">
							<f:validateLength maximum="120"/>
						</h:inputText>
						<h:message for="nomeAluno" showDetail="false" showSummary="true"/>
					</h:panelGroup>
					
					<h:outputLabel value="#{msg.dataNasc}"/>
					<h:panelGroup>
						<p:calendar id="dataNascAluno" label="#{msg.dataNasc}" value="#{usuarioManagedBean.alunoManagedBean.aluno.dataNasc}" required="true" pattern="dd/MM/yyyy" />
						<h:message for="dataNascAluno" showDetail="false" showSummary="true"/>
					</h:panelGroup>
					
					<h:outputLabel value="#{msg.telefone}"/>
					<h:panelGroup>
						<p:inputMask id="telefoneAluno" label="#{msg.telefone}" mask="(99)9999-9999"
						value="#{usuarioManagedBean.alunoManagedBean.aluno.telefone}" required="true" />
						<h:message for="telefoneAluno" showDetail="false" showSummary="true"/>
					</h:panelGroup>
					
					<h:outputLabel value="#{msg.email}"/>
					<h:panelGroup>
						<h:inputText id="emailAluno" label="#{msg.email}" value="#{usuarioManagedBean.alunoManagedBean.aluno.email}" required="true">
							<f:validateRegex pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" />
						</h:inputText>
						<h:message for="emailAluno" showDetail="false" showSummary="true"/>
					</h:panelGroup>
					
					<h:outputLabel value="#{msg.perfil}"/>
					<h:panelGroup>
						<h:inputText id="perfilAluno" label="#{msg.perfil}" value="#{usuarioManagedBean.alunoManagedBean.aluno.perfil}">
							<f:validateLength maximum="300"/>
						</h:inputText>
						<h:message for="perfilAluno" showDetail="false" showSummary="true"/>
					</h:panelGroup>
				</h:panelGrid>
			
			
		
			<h:commandButton value="#{msg.enviar}" actionListener="#{usuarioManagedBean.upload}" action="#{usuarioManagedBean.insere}" />
			
			</h:form>
	</ui:define>
	
</ui:composition>
</h:body> 
</html>